import Vue from 'vue'
import Router from 'vue-router'

import Home from '@/pages/home/Home'
import HomeArticle from '@/pages/home/components/children/article'
// 预约
import Reserve from '@/pages/reserve/Reserve'
import ReserveEvaluation from '@/pages/reserve/components/Evaluation'

import City from '@/pages/city/City'
import Search from '@/pages/search/Search'
import NotFound from '@/pages/notFound/404'
// detail-router
import Detail from '@/pages/detail/Detail'
import Merchant from '@/pages/detail/components/children/merchant/Merchant'
import MerchantOrder from '@/pages/detail/components/children/merchantOrder/order'
import DiscountDetail from '@/pages/detail/components/children/discountsDetail/detail'
// nearby-router
import Nearby from '@/pages/nearby/Nearby'
import OptionAll from '@/pages/nearby/components/childrenComponents/All'
import OptionHotel from '@/pages/nearby/components/childrenComponents/Hotel'
import OptionPlay from '@/pages/nearby/components/childrenComponents/Play'
import OptionEnjoy from '@/pages/nearby/components/childrenComponents/Enjoy'
import OptionDiscounts from '@/pages/nearby/components/childrenComponents/Discounts'
// me-router
import Me from '@/pages/me/Me'
import MeCollect from '@/pages/me/components/children/collect.vue'
import MeEvaluate from '@/pages/me/components/children/evaluate'
import MeFootmark from '@/pages/me/components/children/footmark'
import MeTonghui from '@/pages/me/components/children/TongHui'
import MeVcard from '@/pages/me/components/children/Vcard'
import MeShare from '@/pages/me/components/children/share'
import MeJoin from '@/pages/me/components/children/join'
import MeAbout from '@/pages/me/components/children/about'
// 搜索结果
import SearchResult from '@/pages/searchResult/Result'
import ResultDistance from '@/pages/searchResult/components/distance'
import ResultPopularity from '@/pages/searchResult/components/popularity'
import ResultRecommend from '@/pages/searchResult/components/recommend'
// 分类
import Classify from '@/pages/classify/Classify'
// 授权登录
import Author from '@/pages/author/Author'
// 地图
import MapView from '@/common/map/Map'

Vue.use(Router)

export default new Router({
  linkExactActiveClass: '',
  routes: [
    {
      path: '/',
      redirect: {
        name: 'Home'
      },
      component: Home
    },
    {
      path: '/article/:id',
      name: 'HomeArticle',
      component: HomeArticle
    },
    {
      path: '/author',
      name: 'Author',
      component: Author
    },
    {
      path: '/result',
      redirect: '/result/recommend',
      name: 'SearchResult',
      component: SearchResult,
      children: [
        {
          path: 'distance',
          name: 'ResultDistance',
          component: ResultDistance
        },
        {
          path: 'popularity',
          name: 'ResultPopularity',
          component: ResultPopularity
        },
        {
          path: 'recommend',
          name: 'ResultRecommend',
          component: ResultRecommend
        }
      ]
    },
    {
      path: '/home',
      name: 'Home',
      component: Home,
      children: [
        {
          path: 'article/:id',
          name: 'HomeArticle',
          component: HomeArticle
        }
      ]
    },
    {
      path: '/me',
      name: 'Me',
      component: Me,
      children: [
        {
          path: 'collect',
          name: 'MeCollect',
          component: MeCollect
        },
        {
          path: 'evaluate',
          name: 'MeEvaluate',
          component: MeEvaluate
        },
        {
          path: 'footmark',
          name: 'MeFootmark',
          component: MeFootmark
        },
        {
          path: 'tonghui',
          name: 'MeTonghui',
          component: MeTonghui
        },
        {
          path: 'vcard',
          name: 'MeVcard',
          component: MeVcard
        },
        {
          path: 'share',
          name: 'MeShare',
          component: MeShare
        },
        {
          path: 'join',
          name: 'MeJoin',
          component: MeJoin
        },
        {
          path: 'about',
          name: 'MeAbout',
          component: MeAbout
        }
      ]
    },
    {
      path: '/nearby',
      redirect: '/nearby/enjoy',
      name: 'Nearby',
      component: Nearby,
      children: [
        {
          path: 'all',
          name: 'OptionAll',
          component: OptionAll
        },
        {
          path: 'hotel',
          name: 'OptionHotel',
          component: OptionHotel
        },
        {
          path: 'enjoy',
          name: 'OptionEnjoy',
          component: OptionEnjoy
        },
        {
          path: 'play',
          name: 'OptionPlay',
          component: OptionPlay
        },
        {
          path: 'discounts',
          name: 'OptionDiscounts',
          component: OptionDiscounts
        }
      ]
    },
    {
      path: '/reserve',
      name: 'Reserve',
      component: Reserve,
      children: [
        {
          path: 'evaluation/:id',
          name: 'ReserveEvaluation',
          component: ReserveEvaluation
        }
      ]
    },
    {
      path: '/city',
      name: 'City',
      component: City
    },
    {
      path: '*',
      name: 'NotFound',
      component: NotFound
    },
    {
      path: '/search',
      name: 'Search',
      component: Search
    },
    {
      path: '/detail/:id',
      name: 'Detail',
      component: Detail,
      children: [
        {
          path: 'merchant',
          name: 'Merchant',
          component: Merchant
        },
        {
          path: 'discount',
          name: 'DiscountDetail',
          component: DiscountDetail
        },
        {
          path: 'order',
          name: 'MerchantOrder',
          component: MerchantOrder
        }
      ]
    },
    {
      path: '/classify/:id',
      name: 'Classify',
      component: Classify
    },
    {
      path: '/map',
      name: 'Map',
      component: MapView
    }
  ],
  scrollBehavior (to, from, savedPosition) {
    return { x: 0, y: 0, savedPosition: true }
  }
})
